IF(NOT DEFINED CMAKE_BUILD_TYPE OR x${CMAKE_BUILD_TYPE} STREQUAL "x")
    SET(CMAKE_BUILD_TYPE Debug)
ENDIF()

EXECUTE_PROCESS(COMMAND c++ -dumpversion
        TIMEOUT 5
        OUTPUT_VARIABLE cPlusPlusVerString
        OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[(0-9)]*" cPlusPlusVerNum ${cPlusPlusVerString})

EXECUTE_PROCESS(COMMAND cmake --version
        TIMEOUT 5
        OUTPUT_VARIABLE cMakeVerString
        OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX REPLACE "cmake version " "" cMakeVerNumString ${cMakeVerString})
string(REGEX MATCH "[(0-9).]*" cMakeVerNum ${cMakeVerNumString})

set(OCKIO_CXX_STANDARD "-std=c++11")

SET(OCKIO_COMMON_FLAGS "-D_FILE_OFFSET_BITS=64 -DMETAPOOL_REFINED")

if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
    message(STATUS "x86_64 architecture detected")
    SET(OCKIO_COMMON_FLAGS "${OCKIO_COMMON_FLAGS} -msse2")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
    message(STATUS "aarch64 architecture detected")
else()
    message(STATUS "host processor architecture:$CMAKE_HOST_SYSTEM_PROCESSOR")
endif()

SET(CMAKE_SKIP_RPATH TRUE)
SET(HUAWEI_SECURE_BUILD_FLAGS "-fstack-protector-strong -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -fuse-ld=gold -fPIE -fPIC")
SET(C_COMMON_FLAGS "${C_COMMON_FLAGS} ${OCKIO_C_STANDARD} ${OCKIO_COMMON_FLAGS} -fno-omit-frame-pointer ${HUAWEI_SECURE_BUILD_FLAGS}")
SET(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} ${OCKIO_CXX_STANDARD} ${OCKIO_COMMON_FLAGS} -fno-omit-frame-pointer ${HUAWEI_SECURE_BUILD_FLAGS}")

#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
SET(CMAKE_C_FLAGS_DEBUG "${C_COMMON_FLAGS} -O0 -g")
SET(CMAKE_C_FLAGS_RELEASE "${C_COMMON_FLAGS} -O3 -DNDEBUG=1 -s")
#-mavx -msse4.1
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
SET(CMAKE_CXX_FLAGS_DEBUG "${CXX_COMMON_FLAGS} -O0 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "${CXX_COMMON_FLAGS} -O3 -DNDEBUG=1 -s")



